﻿using System;

class ExtractSentenceWithSubstring
{
    static void Main()
    {
        string text = "We are living in a yellow submarine. We don't have anything else." +
            " Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
        string sequence = "in";
        string[] sentences = text.Split('.');
        string[] newSentences = new string[sentences.Length];

        for (int i = 0; i < sentences.Length; i++)
        {            
            newSentences[i] = " " + sentences[i] + ".";
        }

        for (int i = 0; i < newSentences.Length; i++)
        {
            int index = newSentences[i].IndexOf(sequence, StringComparison.CurrentCultureIgnoreCase);

            while (index != -1)
            {
                char before = newSentences[i][index - 1];
                char after = newSentences[i][index + sequence.Length];

                // Checking if the symbols before and after "in" are letters
                if ((before < 'a' || before > 'z') && (before < 'A' || before > 'Z')
                    && (after < 'a' || after > 'z') && (after < 'A' || after > 'Z'))
                {
                    Console.WriteLine(newSentences[i].Trim());
                }

                index = newSentences[i].IndexOf(sequence, index + 1);
            }
        }
    }
}